<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<?php
	include 'conf/conf.inc.php'; 
	include 'connect/connect.php';
	
	$procurar = '';
	if (isset($_POST["procurar"]))
		  $procurar = $_POST["procurar"];
	
	$selEstado = '24'; // Santa Catarina
	if (isset($_POST["estado"]))
		  $selEstado = $_POST["estado"];
	
	$estado = "SELECT * FROM estado";
	$resEstado = mysql_query($estado, $link);
	
	$municipio = "SELECT * FROM cidade WHERE estado_idestado = $selEstado";
	$resMunicipio = mysql_query($municipio, $link);	
?>

<html>
    <head>
        <meta http-equiv="pragma" content="nocache">
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <script language="javascript" type="text/javascript">
            function submit(){
                document.forms["EstadoMunicipio"].submit();
            }
        </script>
        <link rel=stylesheet href='css/cadastro.css' type='text/css' />
<link rel=stylesheet href='css/estilo.css' type='text/css' />
<script src="js/util.js" type="text/javascript"></script>
<title> <?php echo $title; ?> </title>
    </head>
<body>
<?php include 'menu.php'; ?>
<form id="ListaVendedores" name="ListaVendedores" method="post" action="" >
    <fieldset>
            <legend>Procurar Marcas</legend>
<select name="estado" id="estado" onchange="submit();">
<?php
   while ($row = mysql_fetch_array($resEstado)){       
?>
	<option value="<?php echo $row['idestado'];?>" 
	<?php if ($selEstado == $row['idestado']) echo "selected";?>>
	<?php echo $row['descricao'];?></option>
<?php } ?>
</select>
<input type="text" name="procurar" id="procurar" size="37">
    <button name="acao" id="acao" value="busca"  type="submit">
                <img src="images/form/magnifier.png" alt="Enviar"> Procurar
            </button>
    
      <br><br>
    <table width="100%"   border="1" align="left" id='painel'>
	
	<tr>
        <td width="90" align="center"><b>C&oacute;digo</b></td>
        <td width="400" ><b>Cidade</b></td>
	</tr>
    <?php 
    $sql = "SELECT * FROM cidade WHERE descricao LIKE \"$procurar%\" AND estado_idestado = $selEstado";
	$result = mysql_query($sql, $link);
    
   while ($row = mysql_fetch_array($result)){       
?>
	<tr id = "dados" onMouseOver="javascript:this.style.backgroundColor='#B0C4DE'" onMouseOut="javascript:this.style.backgroundColor=''">
        <td align="center"><?php echo $row['idcidade'];?></td>
        <td width="400"><?php echo $row['descricao'];?></td>
	 </tr>
   <?php } ?>       
    </table>
</fieldset>
</form>
</body>
</html>